﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>毕业设计管理系统</title>
    <link href="<%:Url.Content("~/Content/css/redmond/jquery-ui-1.8.6.custom.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%:Url.Content("~/Content/blackglass.css") %>" rel="stylesheet" type="text/css" />
    <link href="<%:Url.Content("~/Content/css/mainStyle.css") %>" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="<%:Url.Content("~/Scripts/jquery-1.4.3.min.js") %>"></script>
    <script type="text/javascript" src="<%:Url.Content("~/Scripts/jquery-ui-1.8.6.custom.min.js") %>"></script>
    <script type="text/javascript" src="<%:Url.Content("~/Scripts/jquery.blockUI.js") %>"></script>
    <script type="text/javascript" src="<%:Url.Content("~/Scripts/window.manager.editVersion.js") %>"></script>
    <script type="text/javascript" src="<%:Url.Content("~/Scripts/common.js") %>") %>"></script>
    <style type="text/css">
        .ui-dialog .ui-dialog-titlebar-close
        {
            display: none;
        }
    </style>
    <!--[if lt IE 7]>
 <style type="text/css">
 #macdock img,#start-button img { behavior: url(../../Content/iepngfix.htc) }
 </style>
<![endif]-->
<script type="text/javascript">
    $(function () {
        // $("#container").windowsetup();

        $.ajax({
            beforeSend: function () { $.blockUI({ message: "检测Cookie中..." }); },
            url: '<%:Url.Action("IsLogin","Account") %>',
            type: "POST",
            success: function (data) {
                if (data != true) {
                    dialog($("#dialogPanel"), '<%:Url.Action("Login","Account") %>', "载入登陆框中...", { title: "登陆", draggable: false, resizable: false });
                } else {
                    $.unblockUI();
                    $("#dialog").dialog("close");
                    GenreDestopIcon();
                }
            },
            error:function(){
                alert("出现错误了，请联系管理员");
            }
        });




        $("#home").click(function () {
            $("#container").win({
                width: 400,
                height: 300,
                fullscreen: false,
                title: "Admini",
                url: "/Administrator/Index",
                callee: this,
                center: false,
                left: 0,
                top: 0,
                minable: false,
                isIframe: true
            });
        });


        setTimeout(CheckLoginEngine, 5000);
    });
    var MessageNotRead = 0;

    function CheckLoginEngine() {
        $.ajax({
            url: '<%:Url.Action("IsLogin","Account") %>',
            type: "POST",
            success: function (data) {
                if (data != true) {
                    setTimeout(CheckLogineEngine, 15000);
                } else {
                    CheckMessage();
                    GetUserinfo();
                }
            }
        });
    }

    function GetUserinfo() {
        $.ajax({
            url: '<%:Url.Action("GetUserInfo","Json") %>',
            type: "POST",
            success: function (data) {
                $("#userinfo").text("欢迎您！"+data);
            }
        });
    }

    function CheckMessage() {
        $.ajax({
            url: '<%:Url.Action("GetMessageNotRead","Json") %>',
            type: 'POST',
            success: function (data) {
                var count = parseInt(data);

                if (MessageNotRead < data) {
                    var msg = '';
                    if (MessageNotRead != 0) {
                        msg = '您收到' + (count - MessageNotRead) + '条新短信</br>';
                    }
                    msg += '您有' + count + '条未读信息';
                    var div = $('<div class="dockMsgPanel"><p style="margin:10px">' + msg + '</p></div>');
                    div.click(function () {
                        $("#container").win({
                            width: 640,
                            height: 480,
                            fullscreen: false,
                            title: "未读信息",
                            url: '<%:Url.Action("NotReadMessages","Message") %>',
                            callee: this,
                            isIframe: true,
                            uniqueTag: "NotReadMessages_somemeaninglesstag654322131",
                            minable: true,
                            resizable: false
                        });
                    });
                    $("body").append(div);
                    div.fadeIn();
                    var hoverTag = setTimeout(function () { div.fadeOut(function () { div.remove(); }); }, 3000);
                    div.hover(function () {
                        clearTimeout(hoverTag);
                    }, function () {
                        hoverTag = setTimeout(function () { div.fadeOut(function () { div.remove(); }); }, 3000);
                    })
                }
                MessageNotRead = count;
                setTimeout(CheckMessage, 10000);
            },
            error: function () {
                setTimeout(CheckMessage, 10000); 
            }
        });
        
    }
</script>
</head>
<body>
   <div id="errorPanel">
        <table style="width: 100%;">
            <tr>
                <td>
                    <img src="<%=Url.Content("~/content/images/error.jpg") %>" alt="" />
                </td>
                <td style="text-indent: 2em; vertical-align: middle;">
                    <label id="labErrorMsg"></label>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;">
                    <input type="button" id="btnErrorMsg" value="关闭" />
                </td>
            </tr>
        </table>
    </div>
    <div id="dialogPanel" style="display: none;">
    
    </div>
    <div id="container">
        <div id="app">
            <div>
                <a id="home" class="dock-item" href="#">
                    <img src="<%=Url.Content("~/Content/images/icon/home.png")%>" alt="home" /><br />
                    <span>后台管理</span> </a>
            </div>
            <div>
                <a class="dock-item" href="<%:Url.Action("Logout","Account") %>">
                    <img src="<%=Url.Content("~/Content/images/icon/rss2.png")%>" alt="rss" /><br />
                    <span>登出</span></a>
            </div>
        </div>
    </div>
    <!--开始启动菜单的按钮-->
    <div id="start-button" class="start-button">
    </div>
    <div id="start-menu">
    <p id="userinfo">
    </p>
        <ul id="programs">
            <li><a href="<%:Url.Action("Logout","Account") %>">退出</a></li>
           
        </ul>
    </div>
    <!--主界面模拟任务栏部分-->
    <div id="taskbar">
        <div id="dock">
            <div id="dock-inner">
            </div>
        </div>
    </div>

</body>
</html>
